import { defineStore } from 'pinia'
const token = localStorage.getItem('token')
import { getUserInfo } from '@/api'

export default defineStore('user', {
  state: () => ({
    token,
    user: {} as any
  }),
  actions: {
    setToken(token = '') {
      localStorage.setItem('token', token)
      this.token = token
    },
    async getUser() {
      const user = await getUserInfo()
      this.user = user
    }
  }
})